#include <cstdio>

__int64 f[ 31 ][ 31 ];

__int64 C( int n, int r )
{
    if ( f[ n ][ r ] != 0 )
        return f[ n ][ r ];
    return f[ n ][ r ] = C( n, r - 1 ) * ( n - r + 1 ) / r;
}

int main( )
{
    int i, j, t, n, m;
    for ( i = 1; i <= 30; i++ )
    {
        f[ i ][ 0 ] = 1;
        for ( j = 1; j <= i; j++ )
            f[ i ][ j ] = 0;
    }
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d%d", &n, &m);
        if ( n < m )
            puts("0");
        else
            printf("%I64d\n", C( n, m ));
    }
    return 0;
}
